Bad Format String (BFS)

Description:

C# provides a powerful and flexible string formatting mechanism (performed by the System.String.Format method). It is similar to the C language's printf function, but it is safer because in many cases, it is not necessary to specify the types of the parameters. Unfortunately, inconsistencies may exist between the parameter placeholders and the parameters that are actually passed, and the compiler is not able to check for such inconsistencies. BFS helps by detecting situations where the formatting string does not match the passed parameters.

Incorrect:

Console.WriteLine("{1},{2}", 1, 2);
Console.WriteLine("x={0} y={2}", 1, 2, 3);

Correct:

Console.WriteLine("{0},{1}", 1, 2);
Console.WriteLine("x={0} y={1} z={2}", 1, 2, 3);